<?php

declare(strict_types=1);

namespace App\Listener;

use Hyperf\Event\Annotation\Listener;
use Psr\Container\ContainerInterface;
use Hyperf\Event\Contract\ListenerInterface;
use App\Event\LoginEvent;
use App\Model\admin\LogModel;


class LoginListener implements ListenerInterface
{


    public function listen(): array
    {
        return [
            LoginEvent::class,
        ];
    }

    public function process(object $event)
    {
        $data['application_name'] = $event->data['application_name'];
		$data['username'] = $event->data['username'];
		$data['url'] = request()->url();
		$data['ip'] = reaip();
		$data['useragent'] = request()->header('user-agent');
		$data['create_time'] = time();
		$data['type'] = 1;
		
		LogModel::insert($data);
    }
}
